/*无论在什么环境，开发环境板卡为NodeMCU 1.0*/
#include <Arduino.h>

#include "DebugLog.h"
#include "ESP8266WSYBoot.h"
#include "httpd.h"

#include "devices.h"

#define DEFAULT_WIFI_SSID "HAM"
#define DEFAULT_WIFI_PWD "12345678"


#ifdef ENABLE_DEBUG_LOG
Print *DebugLogger = &Serial;
#endif

Httpd http(80);
ESP8266WSYBoot boot;
String hostname;
String password;

void setup() {
    ESP.wdtEnable(5000);
    Serial.begin(115200);

    DEBUG_LOG_LN();
    DEBUG_LOG_LN();

    DEBUG_LOG_LN("[MAIN] setup wifi config");
    
    hostname = HOSTNAME_PREFIX + String(ESP.getChipId(), DEC);
    DEBUG_LOG_LN(hostname);
    boot.setHostname(hostname);
    boot.setDefaultWifi(DEFAULT_WIFI_SSID, DEFAULT_WIFI_PWD);
    boot.setLed(LED_PIN, LED_ON_VAL);
    boot.setBtn(BTN_PIN, BTN_DOWN_VAL);
    boot.begin();
    password = boot.getPassword(); //必须放在boot.begin()后面

    http.begin();

    

    device_setup();

}

void loop() {
    boot.loop();

    device_loop();
}